package com.cakemallproject.mapper;

import com.cakemallproject.pojo.mapperObj.Orders;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrdersMapper {
    @Select("select * from orders where status != 0")
    List<Orders> list();

//    @Insert("insert orders(uid, total, remark, name, phone, address,create_time) values(#{uid},#{total},#{remark},#{name},#{phone},#{address},#{createTime}) ")
    void insert(Orders orders);

    @Select("select * from orders where status != 0 and uid = #{uid} ")
    List<Orders> getByUid(Integer uid);

    @Select("select * from orders where status != 0 and create_time = #{createTime} and uid = #{uid}")
    Orders getByCreateTimeAndUid(@Param("createTime") LocalDateTime createTime,@Param("uid") Integer uid);

    void delete(List<Integer> ids);

    void complete(List<Integer> ids);

    void deliver(List<Integer> ids);

    @Select("select oid from orders where status = #{status}")
    List<Integer> getOidByStatus(Integer status);

    Orders getById(Integer oid);
}
